﻿'*******************************************************************************************
'* Copyright Brügmann Software GmbH, Papenburg
'* Author: Björn Kremer
'* Contact: codeplex<at>patorg.de
'* 
'* VB.CMIS is a VB.NET implementation of the Content Management Interoperability Services (CMIS) standard
'*
'* This file is part of VB.CMIS.
'* 
'* VB.CMIS is free software: you can redistribute it and/or modify
'* it under the terms of the GNU Lesser General Public License as published by
'* the Free Software Foundation, either version 3 of the License, or
'* (at your option) any later version.
'* 
'* VB.CMIS is distributed in the hope that it will be useful,
'* but WITHOUT ANY WARRANTY; without even the implied warranty of
'* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
'* GNU Lesser General Public License for more details.
'* 
'* You should have received a copy of the GNU Lesser General Public License
'* along with VB.CMIS. If not, see <http://www.gnu.org/licenses/>.
'*******************************************************************************************
Imports System.Xml.Serialization
Namespace CMISObjects
   <XmlRoot("object", Namespace:=CmisNamespaceConstants.Cmisra)>
   Public Class CmisFolderObject
      Inherits CMISObject
      Private _parentId As String
      Public Sub New()
         MyBase.New()
      End Sub
      Public Sub New(id As String, properties() As CMISObjectModel.Properties.ICMISProperty, SingleTypeId As String, allowableActions As AllowableActions, parentId As String)
         MyBase.New(id, properties, SingleTypeId, allowableActions)
         _parentId = parentId
      End Sub

      Public Overrides Function GetAtomLinks(baseUri As System.Uri, RepositoryInfo As CMISObjectModel.ServiceDocument.RepositoryInfo) As System.Collections.Generic.List(Of CMISLink)
         Dim retVal As List(Of CMISLink) = MyBase.GetAtomLinks(baseUri, RepositoryInfo)
         retVal.Add(New CMISLink(New Uri(baseUri, ServiceURIs.GetChildrenBase1.Replace("{repositoryId}", RepositoryInfo.RepositoryId).Replace("{id}", Me.Id).TrimStart("/"c)), CmisAtomLinkConstants.Down, CmisContentTypeConstants.Feed))
         If RepositoryInfo.Capabilities.GetDescendants Then
            retVal.Add(New CMISLink(New Uri(baseUri, ServiceURIs.GetDescendantsBase1.Replace("{repositoryId}", RepositoryInfo.RepositoryId).Replace("{id}", Me.Id).TrimStart("/"c)), CmisAtomLinkConstants.Down, CmisContentTypeConstants.Tree))
         End If
         If Not String.IsNullOrEmpty(_parentId) Then
            retVal.Add(New CMISLink(New Uri(baseUri, ServiceURIs.GetObjectBase.Replace("{repositoryId}", RepositoryInfo.RepositoryId).Replace("{id}", _parentId).TrimStart("/"c)), CmisAtomLinkConstants.Up, CmisContentTypeConstants.Entry))
         End If
         If Renditions IsNot Nothing AndAlso Renditions.Count > 0 Then
            retVal.Add(New CMISLink(New Uri(baseUri, ServiceURIs.GetObjectBase.Replace("{repositoryId}", RepositoryInfo.RepositoryId).Replace("{id}", Me.Id).TrimStart("/"c)), CmisAtomLinkConstants.Alternate, CmisContentTypeConstants.Entry))
         End If
         retVal.Add(New CMISLink(New Uri(baseUri, ServiceURIs.GetObjectRelationshipsBase.Replace("{repositoryId}", RepositoryInfo.RepositoryId).TrimStart("/"c).Replace("{id}", Me.Id)), CmisAtomLinkConstants.Relationships, CmisContentTypeConstants.Feed))
         If RepositoryInfo.Capabilities.GetFolderTree Then
            retVal.Add(New CMISLink(New Uri(baseUri, ServiceURIs.GetFolderTreeBase1.Replace("{repositoryId}", RepositoryInfo.RepositoryId).Replace("{id}", Me.Id).TrimStart("/"c)), CmisAtomLinkConstants.FolderTree, CmisContentTypeConstants.Tree))
         End If
         Return retVal
      End Function
   End Class
End Namespace